import http from '@/utils/http';

/**
 * 根据手机获取验证码
 * @param {Object} phone
 */
export function getCode(params){
    return http.get('/users/code', params, { withToken: false }); 
}	

/**
 * 登陆
 * @param {Object} data
 */
export function login(data) {
  return http.post('/users/login', data, { withToken: false }); 
}

/**
 * 获取当前登陆用户id
 */
export function getUserId(){
	return http.get('/users/getUserId');
}

/**
 * 获取当前登陆用户信息
 */
export function getMe(){
	return http.get('/users/me');
}

/**
 * 退出登陆
 */
export function logout(){
	return http.post('/users/logout');
}

/**
 * 根据id获取用户信息
 * @param {Object} id
 */
export function getUserInfo(userId) {
  return http.get(`/users/${userId}`);
}

/**
 * 修改用户信息
 * @param {Object} data
 */
export function updateUserInfo(data) {
  return http.put('/users/update', data);
}

/**
 * 注销账户
 * @param {Object} id
 */
export function deleteUserInfo(id) {
  return http.delete(`/users/delete/${id}`);
}

/**
 * 重置密码
 * @param {Object} data
 */
export function resetPwd(data) {
	return http.put('/users/resetPwd', data);
}
